package com.android.common.constant;


import android.app.Application;
import android.text.TextUtils;
import com.android.common.BuildConfig;
import com.android.common.db.EnvDBHelper;

public class Constant {
    /**
     * http 连接超时
     */
    public static final long HTTP_CONNECT_TIMEOUT = 10000;
    /**
     * http 读超时
     */
    public static final long HTTP_READ_TIMEOUT = 10000;
    /**
     * http 写超时
     */
    public static final long HTTP_WRITE_TIMEOUT = 15000;
    /**
     * http success
     */
    public static final  int SUCCESS = 1;
    /**
     * 登录退出
     */
    public static final  int LOGOUT = 3;
    /**
     * http error
     */
    public static final  int ERROR = 2;
    /**
     * 分页每页条目数
     */
    public static final int PAGE_SIZE = 10;
    /**
     * token key
     */
    public static final String TOKEN_KEY = "tokenId";
    /**
     * 全局 Context
     */
    public static Application GLOBAL_APPLICATION;
    public static final String META_DATA_ACTION_KEY = "action";

    public static final String META_DATA_CATEGORY_KEY = "category";
    /**
     * META_DATA SCHEME
     */
    public static final String META_DATA_SCHEME_KEY = "scheme";
    /**
     * META_DATA HOST
     */
    public static final String META_DATA_HOST_KEY = "host";
    /**
     * META_DATA PORT
     */
    public static final String META_DATA_PORT_KEY = "port";
    /**
     * META_DATA auth_url
     */
    public static final String META_DATA_AUTH_URL_KEY = "auth_url";
    /**
     * META_DATA file_provider_auth
     */
    public static final String META_DATA_FILE_PROVIDER_AUTH_KEY = "file_provider_auth";
    /**
     * file provider auth
     */
    public static final String FILE_PROVIDER_AUTH = "file_provider_auth";
    /**
     * apk 解压类型
     */
    public static final String PACKAGE_ARCHIVE_DATA_TYPE = "application/vnd.android.package-archive";
    /**
     * webView title
     */
    public static final String TOOLBAR_KEY = "toolbarKey";
    /**
     * 权限请求码
     */
    public static final int PERMISSIONS_REQUEST_CODE = 1;
    /**
     * 写存储权限
     */
    public static final int PERMISSION_STORAGE_REQUEST_CODE = PERMISSIONS_REQUEST_CODE + 1;
    /**
     * 相机、相册权限
     */
    public static final int PERMISSION_CAMERA_REQUEST_CODE = PERMISSION_STORAGE_REQUEST_CODE + 1;
    /**
     * 读取电话状态和识别码
     */
    public static final int PERMISSION_PHONE_REQUEST_CODE = PERMISSION_CAMERA_REQUEST_CODE + 1;
    /**
     * 地理位置
     */
    public static final int PERMISSION_LOCATION_REQUEST_CODE = PERMISSION_PHONE_REQUEST_CODE  + 1;
    /**
     * 麦克风位置
     */
    public static final int PERMISSION_MICROPHONE_REQUEST_CODE = PERMISSION_LOCATION_REQUEST_CODE + 1;
    /**
     * 安装apk权限
     */
    public static final int PERMISSION_INSTALL_REQUEST_CODE = PERMISSION_MICROPHONE_REQUEST_CODE + 1;
    /**
     * 录屏请求
     */
    public static final int REQUEST_RECORD_SCREEN = PERMISSION_INSTALL_REQUEST_CODE + 1;
    /**
     * 录音权限
     */
    public static final int PERMISSION_RECORD_AUDIO_REQUEST_CODE = REQUEST_RECORD_SCREEN + 1;
    /**
     *
     */
    public static final int REQUEST_FILE_CHOOSER = 0;
    /**
     * 宽的比例
     */
    public static final float CROP_ASPECT_X = 1;
    /**
     * 高的比例
     */
    public static final float CROP_ASPECT_Y = 1.2f;
    /**
     * 裁剪图片宽
     */
    public static final int CROP_OUTPUT_X = 480;
    /**
     * 裁剪图片高
     */
    public static final int CROP_OUTPUT_Y = 480;
    /**
     * -1
     */
    public static final int INVALID = -1;
    /**
     * 0
     */
    public static final int ZERO = 0;
    /**
     * 1
     */
    public static final int ONE = 1;
    /**
     * 2
     */
    public static final int TWO = 2;
    /**
     * 3
     */
    public static final int THREE = 3;
    /**
     * 4
     */
    public static final int FOUR = 4;
    /**
     * 5
     */
    public static final int FIFE = 5;
    /**
     * 6
     */
    public static final int SIX = 6;
    /**
     *
     */

    /**
     * webView title
     */
    public static final String GO_BACK = "GO_BACK";

    /**
     * webView title
     */
    public static final String CLOSE_PAGE = "CLOSE_PAGE";
    /**
     * webView title
     */
    public static final String LOGIN = "LOGIN";
    /**
     * webView title
     */
    public static final String DOWN_LOAD = "DOWN_LOAD";
    /**
     * webView title
     */
    public static final String SELECT_MEDIA = "SELECT_MEDIA";

    public static final String NOTIFICATION_CHANNEL_KEY = "JPUSH_CHANNEL";
    /**
     * 录屏通知id
     */
    public static final int RECORD_SCREEN_NOTIFICATION_ID = 10086;
    /**
     * 截屏通知id
     */
    public static final int CAPTURE_SCREEN_NOTIFICATION_ID = RECORD_SCREEN_NOTIFICATION_ID + 1;
    public static final String PROJECT_ID = "GSG";
    /**
     * FOLDER NAME
     */
    public static final String ACCESS_LEVEL = "PUBLIC_READ";
    /**
     * 手机号正则
     */
    public static final String PHONE_REGEX = "[1][3456789]\\d{9}";
    /**
     * 身份证号码正则
     */
    public static final String ID_CARD_REGEX = "^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";

    public static String getBaseUrl(){
        String dbServerApiAddress = EnvDBHelper.getInstance(GLOBAL_APPLICATION).queryServerApiAddress();
        String result = TextUtils.isEmpty(dbServerApiAddress) ? BuildConfig.BASE_URL : dbServerApiAddress;
        return result;
    }
    public static String getH5Url(){
        String dbh5Address = EnvDBHelper.getInstance(GLOBAL_APPLICATION).queryH5Address();
        String result = TextUtils.isEmpty(dbh5Address) ? BuildConfig.H5_URL : dbh5Address;
        return result;
    }

    public static String getOtherUrl(){
        String otherAddress = EnvDBHelper.getInstance(GLOBAL_APPLICATION).queryOtherAddress();
        String result = TextUtils.isEmpty(otherAddress) ? BuildConfig.OTHER_URL : otherAddress;
        return result;
    }
}
